package com.core.family.biz.yizhao.controller;

import com.core.common.annotation.MenuDesc;
import com.core.common.manger.wechat.WxOrderService;
import com.core.family.admin.Interceptor.UserUtil;
import com.core.family.admin.config.AuthProperties;
import com.core.family.biz.yizhao.domain.dto.YzUserDto;
import com.core.family.biz.yizhao.domain.po.YzWallet;
import com.core.family.biz.yizhao.domain.req.YzWalletReq;
import com.core.family.biz.yizhao.service.YzWalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import org.springframework.stereotype.Service;
import com.core.common.gen.BaseQuery;
import com.core.common.gen.PageQuery;
import com.core.common.domain.response.R;
import io.swagger.annotations.Api;
import org.springframework.beans.BeanUtils;


/**
 * @author honglei
 * @version 1.0
 * @time: 2023-6-14 17:54:46
 * @Description 服务实现层 钱包表
 */
@MenuDesc(desc = "钱包表", code = "yzWallet")
@Api(tags = "YzWalletController 钱包表")
@RestController
@RequestMapping("/api/YzWallet/")
public class YzWalletController {

    @Autowired
    YzWalletService service;

    @Resource
    AuthProperties authProperties;

    @Autowired
    private WxOrderService wxOrderService;


    /**
     * 付款订单的预支付会话标识
     *
     * @param userId 用户ID
     * @param body   订单信息，{ orderId：xxx }
     * @return 支付订单ID
     */
    @PostMapping("prepay")
    public Object prepay(@RequestBody Map<String,String> map, HttpServletRequest request) {

        return  service.walletRecharge(map,request);


    }


    /**
     * 微信付款成功或失败回调接口
     * <p>
     *  TODO
     *  注意，这里pay-notify是示例地址，建议开发者应该设立一个隐蔽的回调地址
     *
     * @param request 请求内容
     * @param response 响应内容
     * @return 操作结果
     */
    @PostMapping("pay-notify")
    public Object payNotify(HttpServletRequest request, HttpServletResponse response) {
        return wxOrderService.payNotify(request, response);
    }

    /**
     * 订单申请退款
     *
     * @param userId 用户ID
     * @param body   订单信息，{ orderId：xxx }
     * @return 订单退款操作结果
     */
    @PostMapping("refund")
    public Object refund(@RequestBody Map<String,String> map, HttpServletRequest request) {
        return service.walletRefund(map, request);
    }

}
